package mia.dao;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.hibernate.Criteria;
import org.hibernate.Session;

import mia.entity.AdvertisementTypeEntity;
import mia.util.HibernateManager;

public class AdvertisementTypeEntityDAO {

	public static Map<String, AdvertisementTypeEntity> getAdvertisementTypes()
	{
		List<AdvertisementTypeEntity> list = getAdvertisementTypesList();
		Map<String, AdvertisementTypeEntity> map = new HashMap<String, AdvertisementTypeEntity>();
		for(AdvertisementTypeEntity ad : list)
		{
			map.put(ad.getName(), ad);
		}
		return map;
	}
	
	@SuppressWarnings("unchecked")
	public static List<AdvertisementTypeEntity> getAdvertisementTypesList()
	{
		Session session = HibernateManager.getSession();
		Criteria crit = session.createCriteria(AdvertisementTypeEntity.class);
		List<AdvertisementTypeEntity> list = crit.list();
		session.close();
		return list;
	}
}
